angular.module('SmartCanteenApp.wechat', ['ngRoute', 'ngTouch'])

	.config(['$routeProvider', function($routeProvider) {
		$routeProvider.when('/canteen', {
			templateUrl: 'wechatonline/canteen.html',
			controller: 'canteenCtrl'
		});
		$routeProvider.when('/window', {
			templateUrl: 'wechatonline/window.html',
			controller: 'windowCtrl'
		});
		$routeProvider.when('/item', {
			templateUrl: 'wechatonline/item.html',
			controller: 'itemCtrl'
		});
		$routeProvider.when('/order', {
			templateUrl: 'wechatonline/order.html',
			controller: 'orderCtrl'
		});
		$routeProvider.when('/tempAddress', {
			templateUrl: 'wechatonline/tempAddress.html',
			controller: 'tempAddressCtrl'
		});
	}])

	.controller('canteenCtrl', ['$scope', '$timeout','$http', function($scope, $timeout,$http) {
			$scope.hideCanteen()
	//分页清空
				$scope.pagination([]);
    			$scope.initial = '10'; //设置默认每页条数
			$(".modal-dialog").draggable();//为模态对话框添加拖拽
		    $(".modal").css("overflow", "hidden");//禁止模态对话框的半透明背景滚动    		
		    $scope.canteens = [];
		    $scope.choiceCanteen = {};
		    
		    $scope.addImg = true;
		    
		    //图片部分js
			$scope.reader = new FileReader(); //创建一个FileReader接口
			$scope.thumb = {}; //用于存放图片的base64
			var postFiles =[]
			
			$scope.img_upload = function(files) { //单次提交图片的函数
			
				if(files[0].size > 5242880){
				   console.log('图片过大')
				   //myObj.showMessageFromAndroid('图片过大，请重新选择')
				   return
				}
				postFiles.push(files[0])
				console.log(postFiles)
				$scope.guid = (new Date()).valueOf(); //通过时间戳创建一个随机数，作为键名使用
				$scope.reader.readAsDataURL(files[0]); //FileReader的方法，把图片转成base64
				$scope.reader.onload = function(ev) {
					$scope.$apply(function() {
						$scope.thumb[$scope.guid] = {
							imgSrc: ev.target.result, //接收base64
						}
					});
				};
				
				//获取图片长度 判断是否显示加号
				$scope.addImg = false
			};
		
		$scope.img_del = function(key) { //删除，删除的时候thumb和form里面的图片数据都要删除，避免提交不必要的
			console.log($scope.thumb);
			var guidArr = [];
			for(var p in $scope.thumb) {
				guidArr.push(p);
			}
			delete $scope.thumb[guidArr[key]];
			postFiles.splice(key, 1);
			console.log(postFiles)
			console.log(key)
    		$scope.addImg = true
		};
		    
		//展现企业下的所有食堂信息
			$scope.showCanteen = function() {
				//获取食堂信息
				$scope.getJson($scope.resultPath+'/v1/backManage/enterprise/'+localStorage.corporationId+'/canteens',{},'get',function(data){
					
					console.log(data.data)
					$scope.canteens = data.data;
					$scope.pagination($scope.canteens);
					
				})
			}
			$scope.showCanteen();
		$scope.updateCanteenId = '';
		//修改&查看餐别详情
		$scope.editCanteen = function(id) {
			console.log(id);
			$scope.updateCanteenId = id;
			var arr = $scope.canteens ;
			for(var i = 0 ;i < arr.length ; i++){
				if(arr[i].id == id){
						$scope.choiceCanteen = arr[i] ;
				}
			}
			console.log($scope.choiceCanteen)
			$('#detail_Canteen').modal('toggle')
		}
		
		$scope.saveCanteen = function(){
			console.log($scope.choiceCanteen);
			var object = $scope.choiceCanteen.canteenOl ;
			if( isNull(object.longitude) ){
				$scope.showError('精度不能为空');
				return;
			}
			if( isNull(object.latitude) ){
				$scope.showError('纬度不能为空');
				return;
			}
			if( !isDecimal(object.longitude) ){
				$scope.showError('精度必须为数字');
				return;
			}
			if( !isDecimal(object.latitude) ){
				$scope.showError('纬度必须为数字');
				return;
			}
			if( !isNumber( object.minMoney + '') ){
				$scope.showError('起送金额必须为大于等于0的整数');
				return;
			}
			if( !isNumber( object.orderingCost  + '') ){
				$scope.showError('配送费必须为大于等于0的整数');
				return;
			}
			if( !isNumber( object.orderingTime  + '') ){
				$scope.showError('配送时间必须为大于等于0的整数');
				return;
			}
			//目前写死：食堂统一配送
			$scope.choiceCanteen.canteenOl.unifiedDelivery = 1 ;
			
			$scope.getJson($scope.resultPath+'/v1/canteen/'+$scope.updateCanteenId+'/additional',$scope.choiceCanteen,'PUT',function(data){
					
					console.log(data)
					if( data.code == 0){
		 				$scope.showSuccess('操作成功！');
		 				$scope.imageUpload();
		 				$('#detail_Canteen').modal('toggle');
		 				
		 			}else{
		 				$scope.showError(data.msg);
		 			}
				})
			
		}
		
		
		//食堂图片上传
		    	$scope.uploadCanteenImg = function(canteenid,fd){
		    		
		    		console.log(fd);
		    		
		    		$http({
					 	method:'post',
		              	url:$scope.resultPath+"/v1/imageCanteen/"+canteenid+"/upload",
		              	data: fd,
		              	headers: {
			              	'Content-Type':undefined
		              	}
					}).
		            success(function(data) {
		            	console.log(data)
		            	$scope.showCanteen();
		            	$scope.img_del(0);
		            }).
		            error(function(data, status) {
		                console.log(data.msg);
		            });
		    	}
		    	
		    	
		$scope.imageUpload = function(){
			console.log(postFiles);
			var fd = new FormData()
			angular.forEach(postFiles,function(data){
				console.log(data);
				fd.append('files',data)
			})
			console.log(fd);
			if(postFiles.length > 0){
				$scope.uploadCanteenImg($scope.updateCanteenId,fd)
			}
			
		}

}])	


.controller('windowCtrl', ['$scope', '$timeout','$http', function($scope, $timeout,$http) {
			$scope.hideCanteen()
	//分页清空
				$scope.pagination([]);
    			$scope.initial = '10'; //设置默认每页条数
			$(".modal-dialog").draggable();//为模态对话框添加拖拽
		    $(".modal").css("overflow", "hidden");//禁止模态对话框的半透明背景滚动    		
		    $scope.canteens = [];
		    $scope.windows = [];
		    $scope.choiceWindow = {};
		    
		    
		    $scope.addImg = true;
		    
		    //图片部分js
			$scope.reader = new FileReader(); //创建一个FileReader接口
			$scope.thumb = {}; //用于存放图片的base64
			var postFiles =[]
			
			$scope.img_upload = function(files) { //单次提交图片的函数
			
				if(files[0].size > 5242880){
				   console.log('图片过大')
				   //myObj.showMessageFromAndroid('图片过大，请重新选择')
				   return
				}
				postFiles.push(files[0])
				console.log(postFiles)
				$scope.guid = (new Date()).valueOf(); //通过时间戳创建一个随机数，作为键名使用
				$scope.reader.readAsDataURL(files[0]); //FileReader的方法，把图片转成base64
				$scope.reader.onload = function(ev) {
					$scope.$apply(function() {
						$scope.thumb[$scope.guid] = {
							imgSrc: ev.target.result, //接收base64
						}
					});
				};
				
				//获取图片长度 判断是否显示加号
				$scope.addImg = false
			};
			$scope.img_del = function(key) { //删除，删除的时候thumb和form里面的图片数据都要删除，避免提交不必要的
				console.log($scope.thumb);
				var guidArr = [];
				for(var p in $scope.thumb) {
					guidArr.push(p);
				}
				delete $scope.thumb[guidArr[key]];
				postFiles.splice(key, 1);
				console.log(postFiles)
				console.log(key)
	    		$scope.addImg = true
			};
			//查询某个食堂下的档口信息
			$scope.showWindowsByCanteenId = function(canteenId) {
				console.log(canteenId);
				$scope.getJson($scope.resultPath+'/v1/backManage/canteen/'+canteenId+'/windows',{},'get',function(data){
					console.log(data.data)
					$scope.windows = data.data;
					var arr = $scope.windows ;
					for(var i in arr){
						if( arr[i].windowOl.pictureUrl != null && arr[i].windowOl.pictureUrl != ''){
							arr[i].windowOl.path = arr[i].windowOl.path +'?random='+ 	Math.random() ;
						}
					}
					$scope.pagination($scope.windows);
				})
			}
			
			//展现企业下的所有食堂信息
			$scope.showCanteen = function() {
				console.log(112233);
				//获取食堂信息
				$scope.getJson($scope.resultPath+'/v1/backManage/enterprise/'+localStorage.corporationId+'/canteens',{},'get',function(data){
					
					console.log(data.data)
					
					$scope.canteens = data.data;
					if( $scope.canteens.length > 0 ){
						$scope.canteenId = $scope.canteens[0].id;
						$scope.showWindowsByCanteenId($scope.canteenId);
					}
					
					
				})
			}
			$scope.showCanteen();
			$scope.updateWindowId = '';
			$scope.editWindow = function(id){
				console.log(id);
				$scope.updateWindowId = id;
				var arr = $scope.windows ;
				console.log(arr);
				for(var i = 0 ;i < arr.length ; i++){
					if(arr[i].id == id){
						$scope.choiceWindow = arr[i] ;
					}
				}
				console.log($scope.choiceWindow)
				$('#detail_Window').modal('toggle')
			}
			//档口信息维护
			$scope.saveWindow = function(){
				
				//目前写死：食堂统一配送，档口的各种配送信息都为0
				$scope.choiceWindow.windowOl.minMoney = 0 ;//起送金额
				$scope.choiceWindow.windowOl.ordering_time = 0 ;//配送时间
				$scope.choiceWindow.windowOl.orderingCost = 0 ;//配送费
				if( isNull($scope.choiceWindow.windowOl.description) ){
					$scope.choiceWindow.windowOl.description = '暂无描述';
				}
				console.log($scope.choiceWindow);
				
				$scope.getJson($scope.resultPath+'/v1/window/'+$scope.updateWindowId+'/additional',$scope.choiceWindow,'PUT',function(data){
						
						console.log(data)
						if( data.code == 0){
			 				$scope.showSuccess('操作成功！');
			 				$scope.imageUpload();
			 				$('#detail_Window').modal('toggle');
//			 				$scope.showCanteen();
			 			}else{
			 				$scope.showError(data.msg);
			 			}
					})
				
			}
			
			$scope.imageUpload = function(){
				console.log(postFiles);
				var fd = new FormData()
				angular.forEach(postFiles,function(data){
					console.log(data);
					fd.append('files',data)
				})
				console.log(fd);
				if(postFiles.length > 0){
					$scope.uploadWindowImg($scope.updateWindowId,fd)
				}
				
			}
		
			//档口图片上传
		    	$scope.uploadWindowImg = function(windowid,fd){
		    		console.log(windowid);
		    		console.log(fd);
		    		$http({
					 	method:'post',
		              	url:$scope.resultPath+"/v1/imageWindow/"+windowid+"/upload",
		              	data: fd,
		              	headers: {
			              	'Content-Type':undefined
		              	}
					}).
		            success(function(data) {
		            	$scope.showWindowsByCanteenId($scope.canteenId);
		            	$scope.img_del(0);
		            }).
		            error(function(data, status) {
		                console.log(data.msg);
		            });
		    	}
		    //食堂切换档口信息随着切换的接口
		    $scope.changeCanteen = function(){
		    	$scope.showWindowsByCanteenId($scope.canteenId);
		    }
		

}])	


.controller('itemCtrl', ['$scope', '$timeout','$http', function($scope, $timeout,$http) {
			$scope.hideCanteen()
	//分页清空
				$scope.pagination([]);
    			$scope.initial = '10'; //设置默认每页条数
			$(".modal-dialog").draggable();//为模态对话框添加拖拽
		    $(".modal").css("overflow", "hidden");//禁止模态对话框的半透明背景滚动    		
		    $scope.canteens = [];
		    $scope.windows = [];
		    $scope.dishs = [];
		    $scope.choiceCanteen = {};
		    $scope.choiceWindow = {};
		    $scope.choiceItem = {};
		    
		    $scope.addImg = true;
		    
		    //图片部分js
			$scope.reader = new FileReader(); //创建一个FileReader接口
			$scope.thumb = {}; //用于存放图片的base64
			var postFiles =[]
			
			$scope.img_upload = function(files) { //单次提交图片的函数
			
				if(files[0].size > 5242880){
				   console.log('图片过大')
				   //myObj.showMessageFromAndroid('图片过大，请重新选择')
				   return
				}
				postFiles.push(files[0])
				console.log(postFiles)
				$scope.guid = (new Date()).valueOf(); //通过时间戳创建一个随机数，作为键名使用
				$scope.reader.readAsDataURL(files[0]); //FileReader的方法，把图片转成base64
				$scope.reader.onload = function(ev) {
					$scope.$apply(function() {
						$scope.thumb[$scope.guid] = {
							imgSrc: ev.target.result, //接收base64
						}
					});
				};
				
				//获取图片长度 判断是否显示加号
				$scope.addImg = false
			};
			$scope.img_del = function(key) { //删除，删除的时候thumb和form里面的图片数据都要删除，避免提交不必要的
				console.log($scope.thumb);
				var guidArr = [];
				for(var p in $scope.thumb) {
					guidArr.push(p);
				}
				delete $scope.thumb[guidArr[key]];
				postFiles.splice(key, 1);
				console.log(postFiles)
				console.log(key)
	    		$scope.addImg = true
			};
			
			
		    //获取某个档口下的菜品信息
		    $scope.showItemsByWindowId = function(windowId){
		    	console.log(windowId);
		    	$scope.getJson($scope.resultPath+'/v1/backManage/window/'+windowId+'/items',{},'get',function(data){
					console.log(data);
					$scope.dishs = data.data;
					var arr = $scope.dishs ;
					for(var i in arr){
						if( arr[i].itemOl.pictureUrl != null && arr[i].itemOl.pictureUrl != ''){
							arr[i].itemOl.pictureUrl = arr[i].itemOl.pictureUrl +'?random='+ 	Math.random() ;
						}
						
					}
					$scope.pagination($scope.dishs);
					
				})
		    }
		    
		    //查询某个食堂下的档口信息
			$scope.showWindowsByCanteenId = function(canteenId) {
				console.log(canteenId);
				
				$scope.getJson($scope.resultPath+'/v1/backManage/canteen/'+canteenId+'/windows',{},'get',function(data){
					$scope.windows = data.data;
					console.log($scope.windows);
					if( $scope.windows.length > 0 ){
						$scope.windowId = $scope.windows[0].id;
						$scope.showItemsByWindowId($scope.windowId);
					}
				})
			}
			
		 	//展现企业下的所有食堂信息
			$scope.showCanteen = function() {
				//获取食堂信息
				$scope.getJson($scope.resultPath+'/v1/backManage/enterprise/'+localStorage.corporationId+'/canteens',{},'get',function(data){
					console.log(data.data)
					$scope.canteens = data.data;
					if( $scope.canteens.length > 0 ){
						$scope.canteenId = $scope.canteens[0].id;
						$scope.showWindowsByCanteenId($scope.canteenId);
					}
					
					
				})
			}
			$scope.showCanteen();
		    //食堂切换档口信息随着切换
		    $scope.changeCanteen = function(){
		    	$scope.showWindowsByCanteenId($scope.canteenId);
		    }
		    //切换档口菜品信息联动切换
		    $scope.changeWindow = function(){
		    	$scope.showItemsByWindowId($scope.windowId);
		    }
		    $scope.updateDishId = '';
		    $scope.editDish = function(id){
				console.log(id);
				$scope.updateDishId = id;
				var arr = $scope.dishs ;
				console.log(arr);
				for(var i = 0 ;i < arr.length ; i++){
					if(arr[i].id == id){
						$scope.choiceItem = arr[i] ;
					}
				}
				console.log($scope.choiceItem)
				$('#detail_dish').modal('toggle')
			}
		    
		    $scope.imageUpload = function(){
				console.log(postFiles);
				var fd = new FormData()
				angular.forEach(postFiles,function(data){
					console.log(data);
					fd.append('files',data)
				})
				console.log(fd);
				if(postFiles.length > 0){
					$scope.uploadItemImg($scope.updateDishId,fd)
				}
				
			}
		    
		    //菜品图片上传
		    	$scope.uploadItemImg = function(itemid,fd){
		    		console.log(itemid);
		    		console.log(fd);
		    		$http({
					 	method:'post',
		              	url:$scope.resultPath+"/v1/imageItem/"+itemid+"/upload",
		              	data: fd,
		              	headers: {
			              	'Content-Type':undefined
		              	}
					}).
		            success(function(data) {
		            	$scope.showItemsByWindowId($scope.windowId);
		            	$scope.img_del(0);
		            }).
		            error(function(data, status) {
		                console.log(data.msg);
		            });
		    	}
		    	
		    
		    //菜品信息保存
		    $scope.saveItem = function(){
		    	console.log($scope.choiceItem);
				$scope.getJson($scope.resultPath+'/v1/item/'+$scope.updateDishId+'/additional',$scope.choiceItem,'PUT',function(data){
						
					console.log(data)
					if( data.code == 0){
		 				$scope.showSuccess('操作成功！');
		 				$scope.imageUpload();
		 				$('#detail_dish').modal('toggle')
//			 				$scope.showCanteen();
		 			}else{
		 				$scope.showError(data.msg);
		 			}
				})
		    }
		    //一键开通
		    $scope.allDishOpen = function(){
		    	console.log($scope.windowId);
		    	$scope.getJson($scope.resultPath+'/v1/window/'+$scope.windowId+'/updateDishState/'+1,'','PUT',function(data){
					console.log(data)
					if( data.code == 0){
						$scope.showSuccess('操作成功！');
						$scope.showItemsByWindowId($scope.windowId);
		 			}else{
		 				$scope.showError(data.msg);
		 			}
				})
		    }
		    //一键关闭
		    $scope.allDishClose = function(){
		    	console.log($scope.windowId);
		    	$scope.getJson($scope.resultPath+'/v1/window/'+$scope.windowId+'/updateDishState/'+0,'','PUT',function(data){
					console.log(data)
					if( data.code == 0){
						$scope.showSuccess('操作成功！');
						$scope.showItemsByWindowId($scope.windowId);
		 			}else{
		 				$scope.showError(data.msg);
		 			}
				})
		    }

}])	


.controller('orderCtrl', ['$scope', '$timeout','$http','$interval' ,function($scope, $timeout,$http,$interval) {
			$scope.hideCanteen()
	//分页清空
				$scope.pagination([]);
    			$scope.initial = '10'; //设置默认每页条数
			$(".modal-dialog").draggable();//为模态对话框添加拖拽
		    $(".modal").css("overflow", "hidden");//禁止模态对话框的半透明背景滚动    		
		  	$scope.opders = [];
		  	$scope.finishState = 1;//默认商家接单
		  	$scope.canteenId = '';
		  
		  	$scope.orderOneState = function($event,state){
		  		var target = $event.target ;
		  		$(target).addClass('acc');
		  		$(target).siblings().removeClass('acc');
		  		$scope.finishState = state;
		  		$scope.getOrdersByCanteenId($scope.canteenId);
		  	}
		  	
		  	//展现企业下的所有食堂信息
			$scope.showCanteen = function() {
				$scope.getJson($scope.resultPath+'/v1/backManage/enterprise/'+localStorage.corporationId+'/canteens',{},'get',function(data){
					console.log(data)
					$scope.canteens = data.data;
					if( $scope.canteens.length > 0 ){
						$scope.canteenId = $scope.canteens[0].id;
						$scope.getOrdersByCanteenId($scope.canteenId);
					}
				})
			}
			$scope.showCanteen();
			
		  	//查询某个食堂下的所有订单信息
		  	$scope.getOrdersByCanteenId = function(canteenId){
		  		
		  		$scope.getJson($scope.resultPath+'/v1/canteen/'+canteenId+'/getBackOrdersByCanteenIdAndStatus/'+$scope.finishState,{},'get',function(data){
						console.log(data)
						$scope.opders = data.data;
						$scope.pagination($scope.opders);
						
					})
		  		
//		  		if( $scope.finishState == 1){
//		  			$scope.getJson($scope.resultPath+'/v1/canteen/'+canteenId+'/getAllUnfinishedOrdersByCanteenId',{},'get',function(data){
//						console.log(data)
//						$scope.opders = data.data;
//						$scope.pagination($scope.opders);
//						
//					})
//		  		}else if($scope.finishState == 2){
//		  			$scope.getJson($scope.resultPath+'/v1/canteen/'+canteenId+'/getAllFinishedOrdersByCanteenId',{},'get',function(data){
//						console.log(data)
//						$scope.opders = data.data;
//						$scope.pagination($scope.opders);
//						
//					})	
//		  		}
				
		  	}
		  
		  	//轮询订单信息
		  	var timer = $interval(function(){
        		$scope.getOrdersByCanteenId($scope.canteenId);
    		},30000);
//		    timer.then(success,error,notify);
//		    function success(){
//		        console.log("done");
//		    }
//		    function error(){
//			    console.log("error");
//			}
//			function notify(){
//			    console.log("每次都更新");
//			}
			$scope.$on('$destroy',function(){
				console.log('取消轮训器')
			   $interval.cancel(timer);
			}) 
		  	//改变订单状态
		  	$scope.finishOrder = function(serno,state,openId){
		  		console.log(serno);
		  		$scope.getJson($scope.resultPath+'/v1/order/'+serno+'/updateState/'+state+'/andopenid/'+openId,{},'PUT',function(data){
						console.log(data.data)
						$scope.getOrdersByCanteenId($scope.canteenId);
					})	
		  		
		  	}
		  
		  
		  

}])	

.controller('tempAddressCtrl', ['$scope', '$timeout','$http', function($scope, $timeout,$http) {
			$scope.hideCanteen()
	//分页清空
				$scope.pagination([]);
    			$scope.initial = '10'; //设置默认每页条数
			$(".modal-dialog").draggable();//为模态对话框添加拖拽
		    $(".modal").css("overflow", "hidden");//禁止模态对话框的半透明背景滚动    		
		    $scope.canteens = [];
		    $scope.tempAddress = [];
		    $scope.windows = [];
		    $scope.choiceWindow = {};
		    $scope.addImg = true;
		    $scope.updateTempAddressOb={};
		 
			//展现企业下的所有食堂信息
			$scope.showCanteen = function() {
				console.log(112233);
				//获取食堂信息
				$scope.getJson($scope.resultPath+'/v1/backManage/enterprise/'+localStorage.corporationId+'/canteens',{},'get',function(data){
					console.log(data)
					$scope.canteens = data.data;
					if( $scope.canteens.length > 0 ){
						$scope.canteenId = $scope.canteens[0].id;
						$scope.canteenCode = $scope.canteens[0].canteenOl.qrcode;
						$scope.showAllTempAddress();
					}
					
				})
			}
			$scope.showCanteen();
			
			//获取该食堂下的临时地址信息
			$scope.showAllTempAddress = function() {
				console.log($scope.canteenCode);
				//获取临时地址信息
				$scope.getJson($scope.resultPath+'/v1/canteen/'+$scope.canteenCode+'/tempAddress',{},'get',function(data){
					console.log(data)
					$scope.tempAddress = data.data;
				})
			}
			
			//新增地址弹出页
			$scope.newTempAddress = function(){
				
				$('#newTempAddress').modal('toggle');
			}
			
			//新增地址
			$scope.saveNewTempAddress = function(){
				//console.log($scope.newTempAddressOb.name);
				$scope.newTempAddressOb.canteencode=$scope.canteenCode;
				$scope.newTempAddressOb.page='pages/index/index';
				$scope.getJson($scope.resultPath+'/v1/generateqrcode',$scope.newTempAddressOb,'post',function(data){
					console.log(data)
					if( data.code == 0){
						$scope.showSuccess('操作成功！');
						$('#newTempAddress').modal('toggle');
						$scope.showAllTempAddress();
		 			}else{
		 				$scope.showError(data.msg);
		 			}
				})
			}
			
			//修改地址弹出页
			$scope.toUpdateTempAddressPage = function(id){
				$scope.updateTempAddressOb.id=''
				$scope.updateTempAddressOb.address=''
				$('#updateTempAddress').modal('toggle');
				$scope.updateTempAddressOb.id=id;
			}
			
			//修改地址
			$scope.updateTempAddress = function(){
				console.log($scope.updateTempAddressOb);
				$scope.getJson($scope.resultPath+'/v1/updateqrcode',$scope.updateTempAddressOb,'put',function(data){
					console.log(data)
					if( data.code == 0){
						$scope.showSuccess('操作成功！');
						$('#updateTempAddress').modal('toggle');
						$scope.showAllTempAddress();
		 			}else{
		 				$scope.showError(data.msg);
		 			}
				})
			}
			
			//删除地址
			$scope.delTempAddress = function(id){
				$scope.getJson($scope.resultPath+'/v1/deleteqrcode/'+id,{},'post',function(data){
					console.log(data)
					if( data.code == 0){
						$scope.showSuccess('操作成功！');
						$scope.showAllTempAddress();
		 			}else{
		 				$scope.showError(data.msg);
		 			}
				})
			}
		

}])	




